<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
	<title>login</title>
</h:head>
<h:body>
	<ui:composition template="/pages/common/commonLayout.xhtml">
		<ui:define name="content">
			<h:messages errorStyle="color: purple;" />
			<h:form id="formularzLogowania">
				<p:panel header="Logowanie" style="width: 420px;"
					rendered="#{!loginBean.registration}">
					<h:panelGrid id="loginPanel" columns="2">
						<h:outputText value="Username" />
						<p:inputText id="username" value="#{loginBean.uname}"
							required="true">
						</p:inputText>
						<p:spacer></p:spacer>
						<p:message for="username" />
						<h:outputText value="Password" />
						<p:password id="password" value="#{loginBean.password}"
							feedback="false" required="true">
						</p:password>
						<p:spacer></p:spacer>
						<p:message for="password" />
						<p:spacer></p:spacer>
						<p:commandButton action="#{loginBean.loginProject}" value="Login"
							update="formularzLogowania" ajax="true" />
						<p:spacer></p:spacer>
					</h:panelGrid>
				</p:panel>
				<p:panel header="Rejestracja" rendered="#{loginBean.registration}">
					<h:panelGrid id="register" columns="4">
						<h:outputText value="Login" />
						<p:inputText id="login"
							value="#{loginBean.registeredUser.login}" required="true" requiredMessage="Pole login wymagane">
							<f:validateLength minimum="6" maximum="20" />
						</p:inputText>
						<h:outputText value="Imie" />
						<p:inputText id="imie"
							value="#{loginBean.registeredUser.firstName}" required="true" requiredMessage="Pole imie wymagane">
							<f:validateLength minimum="3" maximum="20" />
						</p:inputText>
						<h:outputText value="Nazwisko" />
						<p:inputText id="nazwisko"
							value="#{loginBean.registeredUser.lastName}" required="true"  requiredMessage="Pole nazwisko wymagane">
							<f:validateLength minimum="2" maximum="20" />
						</p:inputText>
						<h:outputText value="Pesel" />
						<p:inputText id="Pesel" value="#{loginBean.registeredUser.pesel}"
							required="true" requiredMessage="Pole pesel wymagane">
							<f:validateLength minimum="11" maximum="11" />
						</p:inputText>
						<h:outputText value="Haslo" />
						<p:password id="haslo" requiredMessage="Pole haslo wymagane"
							value="#{loginBean.registeredUser.password}" required="true"
							feedback="true" promptLabel="Sila hasla" weakLabel="Slabe"
							match="potwierdzenieHasla" goodLabel="Dobre" strongLabel="Mocne">
							<f:validateLength minimum="4" maximum="20" />
						</p:password>
						<h:outputText value="Potwierdz haslo" />
						<p:password id="potwierdzenieHasla" value="#{loginBean.passwordCheck}"
							required="true" feedback="false" requiredMessage="Pole potwierdzenie hasla wymagane">
							<f:validateLength minimum="4" maximum="20" />
						</p:password>
						<h:outputText value="Typ konta" />
						<p:selectOneMenu id="accType" required="true" requiredMessage="Pole wymagane"
							value="#{loginBean.registeredUser.accType}">
							<f:selectItems value="#{enumBean.accountTypes}" var="type"
								itemValue="#{type}" itemLabel="#{type.label}" />
						</p:selectOneMenu>
						<p />
						<p:commandButton action="#{loginBean.registerUser}"
							value="Zarejestruj" ajax="false" />
					</h:panelGrid>
				</p:panel>
			</h:form>
			<p:commandButton action="#{loginBean.toLogin}" value="Logowanie"
				update="@all" ajax="true" rendered="#{loginBean.registration}" />
			<p:commandButton action="#{loginBean.register}" value="Rejestracja"
				update="@all" ajax="true" rendered="#{!loginBean.registration}" />
		</ui:define>
	</ui:composition>
</h:body>
</html>